package br.com.criativasystem.helper;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Classe responsavel pela manutenção de datas
 * @author Lucas Calixto 
 */
public class DataHelper {
    
    private SimpleDateFormat dataCompleta = new SimpleDateFormat("dd/MM/yyyy hh:mm");
    private SimpleDateFormat dataSimple = new SimpleDateFormat("dd/MM/yyyy");
    private SimpleDateFormat dataBanco = new SimpleDateFormat("yyyy-MM-dd hh:mm");
    
    public String dataCompleta(Date data) {
        if(data == null || data.equals("")) {
            return "";
        } else {
            return dataCompleta.format(data);
        }
    }
    
    public String dataSimples(Date data) {
        if(data == null || data.equals("")) {
            return "";
        } else {
            return dataSimple.format(data);
        }
    }
    
    public String dataBanco(Date data) {
        if(data == null || data.equals("")) {
            return "";
        } else {
            return dataBanco.format(data);
        }
    }
    
    public Date parseDataSimples(String data) throws ParseException {
        if(data == null || data.equals("")) {
            return null;
        } else {
            return dataCompleta.parse(data);
        }
    }
}
